package dy.spec.edu.week12_class02;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button button = (Button) findViewById(R.id.button);
        Button button1 = (Button) findViewById(R.id.button1);
        button.setOnClickListener(btnlistener);
        button1.setOnClickListener(btnlistener);

    }
    private View.OnClickListener btnlistener=new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(v.getId()==R.id.button){
                Intent intent=new Intent();
                intent.setClass(MainActivity.this,SecondActivity.class);
                startActivity(intent);
            }
            else if(v.getId()==R.id.button1){
                Intent intent=new Intent();
                intent.setClass(MainActivity.this,FirstActivity.class);
                startActivity(intent);
            }
        }
    };
}
